<?xml version='1.0' encoding='UTF-8' ?>

<ui:composition xmlns="http://www.w3.org/1999/xhtml"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:ui="http://java.sun.com/jsf/facelets"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns:fn="http://java.sun.com/jsp/jstl/functions"
                xmlns:h="http://java.sun.com/jsf/html"
                template="/WEB-INF/templates/default.xhtml">

    <ui:define name="content">
        #{msg['form.add']} #{msg['default.package']}:
        <br/>
        <h:outputText rendered="#{packageManager.atLeastOnePackageCreated}" value="#{msg['default.package']} #{msg['package.created']}"/>
        <h:form>
            <h:outputLabel value="#{msg['package.height']}" for="newPackageHeight" />
            <h:inputText id="newPackageHeight" value="#{packageManager.addHeight}" validatorMessage="#{msg['error.form.number']}">
                <f:validateLongRange minimum="0" />
            </h:inputText><br/>
            <h:message for="newPackageHeight" errorClass="invalid" />

            <h:outputLabel value="#{msg['package.width']}" for="newPackageWidth" />
            <h:inputText id="newPackageWidth" value="#{packageManager.addWidth}" validatorMessage="#{msg['error.form.number']}">
                <f:validateLongRange minimum="0" />
            </h:inputText><br/>
            <h:message for="newPackageWidth" errorClass="invalid" />

            <h:outputLabel value="#{msg['package.weight']}" for="newPackageWeight" />
            <h:inputText id="newPackageWeight" value="#{packageManager.addWeight}" validatorMessage="#{msg['error.form.number']}">
                <f:validateLongRange minimum="0" />
            </h:inputText><br/>
            <h:message for="newPackageWeight" errorClass="invalid" />

            <h:outputLabel value="#{msg['package.price']}" for="newPackagePrice" />
            <h:inputText id="newPackagePrice" value="#{packageManager.addPrice}" validatorMessage="#{msg['error.form.number']}">
                <f:validateDoubleRange minimum="0.0"/>
            </h:inputText><br/>
            <h:message for="newPackagePrice" errorClass="invalid" /><br/>
            
            <h:commandButton class="btn" action="#{packageManager.createPackage}" value="#{msg['form.add']} #{msg['default.package']}" />
            <h:commandButton class="btn" rendered="#{packageManager.atLeastOnePackageCreated}" action="#{deliveryManager.finishAddingPackages}" value="#{msg['form.finish']}" />
        </h:form>
    </ui:define>
</ui:composition>

